package hlhj.fhp.supreme.activitys

import android.support.v4.view.ViewPager
import android.widget.Button
import android.widget.LinearLayout
import fhp.hlhj.giantfold.utils.LogUtil
import hlhj.fhp.supreme.BaseAty
import hlhj.fhp.supreme.R
import hlhj.fhp.supreme.adapters.NavPagerAdp
import hlhj.fhp.supreme.utils.SPHelper
import kotlinx.android.synthetic.main.nav_aty.*

/**
 * Created by Administrator on 2018\6\11 0011.
 */
class NavAty :BaseAty(), ViewPager.OnPageChangeListener {
    private lateinit var pagerAdp:NavPagerAdp
    override fun getContentId(): Int {
        return R.layout.nav_aty
    }

    override fun initView() {
        pagerAdp= NavPagerAdp(this)
        viewPager.adapter=pagerAdp
        SPHelper.saveIsFirst(this,false)
        LogUtil.log("再次获取设置的${SPHelper.getIsFirst(this)}")
        for (j in 0..2) {
            val bt = Button(this@NavAty)
            bt.setBackgroundResource(R.drawable.radiobt_slct)
            val params = LinearLayout.LayoutParams(this.resources.getDimension(R.dimen.indector).toInt(), this.resources.getDimension(R.dimen.indector).toInt())
            params.setMargins(10, 0, 0, 0)
            bt.layoutParams = params
            loInd.addView(bt)
            val childAt = loInd.getChildAt(0)
            childAt.setBackgroundResource(R.drawable.radiobt_slct1)
        }
        viewPager.addOnPageChangeListener(this)


    }

    override fun onPageScrollStateChanged(state: Int) {
    }

    override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
    }

    override fun onPageSelected(position: Int) {
        for (i in 0 until loInd.childCount) {
            val childAt = loInd.getChildAt(i)
            childAt.setBackgroundResource(R.drawable.radiobt_slct)
        }
        loInd.getChildAt(position).setBackgroundResource(R.drawable.radiobt_slct1)
    }
}